package tjs.study.notes.queue.producer.kafka;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import tjs.study.notes.queue.producer.kafka.defaultStream.SendService;
import tjs.study.notes.queue.producer.kafka.initial.InitialKafkaService;
import tjs.study.notes.queue.producer.kafka.myStream.MySendService;

/**
 * http://127.0.0.1:7888/kafka/sendMy/111
 */
@RestController
@RequestMapping("/kafka")
public class ProducerController {

    @Autowired
    private SendService sendService;
    @Autowired
    private MySendService mySendService;
    @Autowired
    private InitialKafkaService initialKafkaService;

    @RequestMapping("/send/{msg}")
    public String send(@PathVariable("msg") String msg) {
        sendService.sendMsg(msg);
        return "发送成功：" + msg;
    }

    @RequestMapping("/sendMy/{msg}")
    public String sendMy(@PathVariable("msg") String msg) {
        mySendService.sendMsg(msg);
        return "发送成功：" + msg;
    }

    //http://127.0.0.1:7888/kafka/sendInitial/nicky_init/aaaa
    @RequestMapping("/sendInitial/{channel}/{msg}")
    public String initial(@PathVariable("channel") String channel, @PathVariable("msg") String msg) {
        initialKafkaService.sendMsg(channel, msg);
        return "发送成功：" + msg;
    }
}